package com.jp.knowledge.fragment;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.View;

import com.google.gson.JsonObject;
import com.jp.knowledge.http.HttpHelper;

/**
 * Created by 528787067@qq.com on 2017/7/11.
 */

public class PackageListFragment extends ProductEvluationBaseFragment {
	public static PackageListFragment newInstance(int type){
		PackageListFragment fragment = new PackageListFragment();
		Bundle bundle = new Bundle();
		bundle.putInt("type", type);
		fragment.setArguments(bundle);
		return fragment;
	}

	private int page;

	@Override
	public void onCreate(@Nullable Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		cachePath = mContext.getCacheDir() + "/discover_package_list_" + type + ".dat";
	}

	@Override
	protected void getData(int mode) {
		if(mode == REFRESH_CODE)
			page = 1;
		else
			++page;
		JsonObject param = new JsonObject();
		param.addProperty("type", type);
		param.addProperty("page", page);
		HttpHelper.getInstance(mContext).discoverPackageList(param, mode, this);
	}
}
